home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / WalkT / geo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-20  |  2.5 KB  |  63 lines

  1. /**********************************************************************/
  2. /* Geometric primitives (general)                                     */
  3. /*                                                                    */
  4. /* Copyright (C) 1992, Bernard Kwok                                   */
  5. /* All rights reserved.                                               */
  6. /* Revision 1.0                                                       */
  7. /* May, 1992                                                          */
  8. /**********************************************************************/
  9. #ifndef GEO_H
  10. #define GEO_H
  11.  
  12. #ifndef IRIS4D
  13. typedef float Matrix[4][4];              /* 4x4 transformation matrix */
  14. static Matrix Identity = {
  15.   1.0, 0.0, 0.0, 0.0,
  16.   0.0, 1.0, 0.0, 0.0,
  17.   0.0, 0.0, 1.0, 0.0,
  18.   0.0, 0.0, 0.0, 1.0
  19.   };
  20. #endif 
  21.  
  22. typedef struct { double x,y,z; } Vector; /* 3D Vector */
  23. typedef struct { double x,y,z; } point3; /* 3D Point */
  24. typedef struct {double x,y,z,h;} point4; /* 4D Point */
  25. typedef struct {  
  26.   Vector n;                      /* normal */
  27.   Vector p;                      /* point on plane */
  28.   double d;                      /* distance from origin to plane */
  29. } Plane;                         /* A plane */
  30.  
  31. typedef struct {               
  32.   point3 start;                  /* Start point */
  33.   Vector dir;                    /* vector direction */
  34. } Line;                          /* A line */
  35.  
  36. typedef struct {
  37.   Vector min, max;              /* Upper and lower bounds of box */
  38. } BoundingBoxType;               /* bounding box (axis aligned) */
  39.  
  40. /**********************************************************************/
  41. double dot();                    /* dot product */
  42. Vector cross();                  /* cross product */
  43. double norm();                   /* vector normalization */
  44. double geo_line();               /* vector from 2 pts */
  45. Vector *vadd();                  /* vector add */
  46. Vector *vsub();                  /* vector subtract */
  47. Vector *vcomb();                 /* linear combination of 2 vectors */
  48. double vdist();
  49. Vector polynorm();               /* polygon normal from vertices */
  50. double Power();                  /* fast power function for positive ints */
  51.  
  52. void copymatrix();               /* copy matrices */
  53. void multmatrix();               /* multiply 2 matrices */
  54. Vector vtransform();             /* Matrix * vector */
  55. static int invertmatrix();       /* Invert matrix */
  56.  
  57. void print_vector();             /* print 3D vector */
  58. void print_matrix();             /* print a 4x4 matrix */
  59.  
  60. #endif /* GEO_H */
  61.  
  62.  
  63.